package com.xie.dome.searchservice.controller;

import com.xie.dome.searchservice.model.ResultSet;
import com.xie.dome.searchservice.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author xie
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/dataList")
    public ResultSet findDataList(@RequestParam("showName") String showName) {
        ResultSet resultSet = new ResultSet();
        try {
            List<Map<String, Object>> list = userService.findDataList(showName);
            resultSet.setCode(100);
            resultSet.setResult(list);
        } catch (Exception e) {
            resultSet.setCode(200);
            resultSet.setMessage(e.getMessage());
        }
        return resultSet;
    }

}
